<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>30.getter和setter</title>
</head>
<body>
<script>
  class Phone {
    constructor(name,price) {
      this._price = price
      this._name = name
    }

    get price(){
      return this._price
    }

    set price(newPrice){
      this._price = newPrice
    }
    
    get name(){
      return this._name
    }
  }

  var phone = new Phone('zz',1999)
  console.log(phone.price)
  phone.price =  2299
  console.log(phone.price)
  phone.name = 'huawei'
  console.log(phone.name)
</script>
</body>
</html>